﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教学运行 - 教学场地调度 - 教室借用向导");
		
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		
		termId = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		termDateStart = event.getArg("DateStart");
		
		/* 起始周 */
		w1 = event.getArg("W1");
		/* 结束周 */
		w2 = event.getArg("W2");
		/* 星期几 */
		wkday = event.getArg("WKDAY");
		/* 时段 */
		wkcell = event.getArg("CELL");
		/* 校区 */
		campusId = event.getArg("CAMP");
		/* 教室类别 */
		roomType = event.getArg("CT");
		/* 教室座位 */
		roomSize = event.getArg("SIZE");
		
		/* 教室列表 */
		roomIds = event.getArg("ROOMIDS");
		
		/* 借用单位 */
		instituteId = sessionAdvice.getUserProp('teacherDepartment');
		
		/* 借用教室名称 */
		sql = "SELECT cr_id, classroom FROM t_classroom WHERE cr_id IN (:Ids) ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="Ids", value=arrayToList(listToArray(roomIds, "|"), ","), cfsqltype="cf_sql_char", list=true );
		
		rs_room = queryObj.execute( sql=sql ).getResult();
		
		
		/* 教室使用类别 */
		sql = "SELECT ut_id, usage 
				FROM t_clsroom_usetype 
				WHERE 
					ut_id NOT IN ( :typeIds )
				ORDER BY ut_id ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="typeIds", value="4,6", cfsqltype="cf_sql_char", list=true );
		
		rs_type = queryObj.execute( sql=sql ).getResult();
		
		passArgs = structNew();
		structInsert( passArgs, "W1", w1 );
		structInsert( passArgs, "W2", w2 );
		structInsert( passArgs, "WKDAY", wkday );
		structInsert( passArgs, "CELL", wkcell );
		structInsert( passArgs, "CAMP", campusId );
		structInsert( passArgs, "CT", roomType );
		structInsert( passArgs, "SIZE", roomSize );
		
		currentTab = event.getArg("Tab", "labSign");
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">教学场地调度</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 info"></i>教室借用申请
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab2">
					<div class="tabLables">
						<span <cfif currentTab eq "labSign">class="active"</cfif> id="labSign" tabTarget="Sign">教室借用申请</span>
						<span <cfif currentTab eq "labTeacher">class="active"</cfif> id="labTeacher" tabTarget="Teacher">申请人</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
					
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
								
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				
				<div id="Sign" class="tabContent">
					
					<div class="noticeBlock">
						<div class="operation">
							<a class="uiButton" href="<cfoutput>#buildURL('classRoomBorrowRoomList', passArgs)#</cfoutput>"><i class="mrs img btnCampus"></i><span class="uiButtonText">更换教室</span></a>
						</div>
						<h3>选择教学区域</h3>
						<p><span class="img icon16x16 message"></span>请根据实际情况, 如实填写借用申请</p>
						<hr/>
					</div>
					
					<cfif rs_room.recordCount >
							
							<form id="formSign" onSubmit="javascript:return processVerfiyForm('formSign');" class="formWrapper" method="post" action="<cfoutput>#buildURL('classRoomBorrowSignDo')#</cfoutput>">
								
								<input name="W1" type="hidden" value="<cfoutput>#w1#</cfoutput>" />
								<input name="W2" type="hidden" value="<cfoutput>#w2#</cfoutput>" />
								<input name="WKDAY" type="hidden" value="<cfoutput>#wkday#</cfoutput>" />
								<input name="CELL" type="hidden" value="<cfoutput>#wkcell#</cfoutput>" />
								
								<input name="ROOMIDS" type="hidden" value="<cfoutput>#valueList( rs_room.cr_id, '|' )#</cfoutput>" />
								<input name="TermID" type="hidden" value="<cfoutput>#termId#</cfoutput>" />
								
 								<input name="TimeDescription" type="hidden" value="<cfif w1 eq w2>第<cfoutput>#w1#</cfoutput>周<cfelse>第<cfoutput>#w1#</cfoutput>至<cfoutput>#w2#</cfoutput>周</cfif><cfoutput>#mathAdvice.convertWeekDayToChinese(wkday)#</cfoutput><cfoutput>#mathAdvice.convertLectureIdxToChinese(wkcell)#</cfoutput>" />
 								<input name="RoomDescription" type="hidden" value="借用教室<cfoutput>#valueList( rs_room.classroom, '/')#</cfoutput>, 共<cfoutput>#rs_room.recordCount#</cfoutput>间" />
								<input name="InstituteID" id="InstituteID" type="hidden" value="<cfoutput>#instituteId#</cfoutput>" />
								<input name="TeacherID" id="TeacherID" type="hidden" value=""/>
								<input name="Signer" id="Signer" type="hidden" value="" />
								
								<div class="label">
									<b>借用教室</b>
									<p>
										共<strong><cfoutput>#rs_room.recordCount#</cfoutput></strong> 间: 
										<cfoutput>#valueList( rs_room.classroom, ", " )#</cfoutput>
									</p>
								</div>
								
								<div class="label">
									<b>使用时段</b>
									<p>
										<cfif w1 eq w2>
											第<cfoutput>#w1#</cfoutput>周
											<cfelse>
											第<cfoutput>#w1#</cfoutput>至<cfoutput>#w2#</cfoutput>周
										</cfif>
										<cfoutput>#mathAdvice.convertWeekDayToChinese(wkday)#</cfoutput>
										<cfoutput>#mathAdvice.convertLectureIdxToChinese(wkcell)#</cfoutput>
									</p>
								</div>
								
								<div class="label">
									<b>责任教师</b>
									<input name="TeacherName" id="TeacherName" type="text" disabled="disabled" class="typeTextDynamic " verification="required" value="" /><span id="teacherTrigger" class="btnSearch"></span>
									<p class="notice">请选择教室申请人, 该教师对上述时段教室用途, 设备安全直接负责</p>
								</div>
								
								<div class="label">
									<b>使用类别</b>
									<cfloop query="rs_type">
										<input type="radio" name="UsageType" <cfif rs_type.ut_id eq "1">checked="checked"</cfif> class="typeRadio" value="<cfoutput>#rs_type.ut_id#</cfoutput>" />
										<cfoutput>#rs_type.usage#</cfoutput>
									</cfloop>
								</div>
								
								<div class="lable">
									<input class="button" type="submit" value="提交申请" />
								</div>

							</form>
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {

									$("#teacherTrigger").click(function(){
										
										$("div.tabLables span").removeClass("active");
										$("div.tabLables span#labTeacher").addClass("active");
							
										$("div.tabContent").not('[id="Teacher"]').hide();
										$("div.tabContent#Teacher").show();
										
									});

								});
								// -->
								//]]>
							</script>
							
							
						<cfelse>
							<div class="systemNotice">
								<p>没有指定教室</p>
							</div>
					</cfif>

				</div>
				
				<div id="Teacher" class="tabContent">
					
					<form id="formSearch" class="formWrapper Transparent" method="post">
						<div class="label">
							<b>教师姓名或职工号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索教师" />
							<input id="formSearchReset" class="button" type="button" value="返回" />
						</div>
					</form>
					
					<div id="formSearchResult" class="UICardTable"></div>
					
					<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {

									$("#formSearchReset").click(function(){

										$("div.tabLables span").removeClass("active");
										$("div.tabLables span#labSign").addClass("active");
							
										$("div.tabContent").not('[id="Sign"]').hide();
										$("div.tabContent#Sign").show();
									});
									
									$("#formSearch").submit(function(){
								
										if (processVerfiyForm('formSearch')) {
									
											$.getJSON(
													'<cfoutput>#buildURL("getTeacherByKeywords")#</cfoutput>',
													{
														'Keywords': $("form#formSearch input#Keywords").val(),
														'seed': (new Date()).getTime()
													},
													function(data) {
														
														$div = $("div#formSearchResult").html("").removeClass("hidden_elem");
												
														for (var i=0; i<data.length; i++) {
											
															var $element = $("<dl><dt><a><i class='sex" + data[i][2] + "'></i><dd><h3>" + data[i][1] + " [" + data[i][3] + "]" + "</h3><p>(" + data[i][0] + ")</p></dd></a></dt></dl>");
													
															$element
																.attr({
																	'TeacherID' : data[i][0],
																	'TeacherName' : data[i][1],
																	'InstituteID' : data[i][2]
																})
																.click(function(){
																
																	var teacherName = $(this).attr('TeacherName');
																	var teacherId = $(this).attr('TeacherID');
																	var instituteId = $(this).attr('InstituteID');
															
																	$("form#formSign input#TeacherID").val(teacherId);
																	$("form#formSign input#TeacherName").val(teacherName + "(" + teacherId + ")");
																	$("form#formSign input#InstituteID").val(instituteId);
																	$("form#formSign input#Signer").val(teacherName + "(" + teacherId + ")");

																	$("div.tabLables span").removeClass("active");
																	$("div.tabLables span#labSign").addClass("active");
							
																	$("div.tabContent").not('[id="Sign"]').hide();
																	$("div.tabContent#Sign").show();

																})
																.appendTo($div);
													
														}
												
													});
								
										}
								
										return false;
									});
									
								
								});

								// -->
								//]]>
							</script>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>



